home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Orlando_1993 / Devcon93.4 / CAMD / examples / newexamples / linktest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-31  |  3.7 KB  |  180 lines

  1.  
  2. #ifndef AZTEC_C
  3. #include <clib/alib_protos.h>
  4. #include <clib/alib_stdio_protos.h>
  5. #include <clib/cia_protos.h>
  6. #include <clib/dos_protos.h>
  7. #include <clib/exec_protos.h>
  8. #include <clib/misc_protos.h>
  9. #include <clib/timer_protos.h>
  10. #include <clib/utility_protos.h>
  11.  
  12. #include <stdlib.h>
  13. #endif
  14.  
  15. #if 0
  16.     /* locally defined pragmas */
  17. #include "sys_pragmas.h"
  18. #include "pragmas/dos_pragmas.h"
  19. #include "pragmas/misc_pragmas.h"
  20. #include "pragmas/timer_pragmas.h"
  21. #include "pragmas/utility_pragmas.h"
  22. #endif
  23.  
  24. #include "midi/camd.h"
  25. #include "midi/mididefs.h"
  26. #include "clib/camd_protos.h"
  27. #include "pragmas/camd_pragmas.h"
  28.  
  29. struct Library    *CamdBase;
  30.  
  31. struct MidiNode    *testnode;
  32. struct MidiLink *outlink,
  33.                 *inlink;
  34.  
  35. char            a_sys_ex[] = { MS_SysEx, 8, 7, 6, 5, 4, 3, 2, 1, MS_EOX };
  36. char            b_sys_ex[128];
  37.  
  38. char            r_sys_ex[] = { MS_SysEx, 0x41, 0x07, 0x14, 0x11, 0,0,0,
  39.                                 0,0,0x10, 0x70, MS_EOX };
  40.     /* stub functions */
  41.  
  42. struct MidiNode *CreateMidi(Tag tag, ...)
  43. {    return CreateMidiA((struct TagItem *)&tag );
  44. }
  45.  
  46. BOOL SetMidiAttrs(struct MidiNode *mi, Tag tag, ...)
  47. {    return SetMidiAttrsA(mi, (struct TagItem *)&tag );
  48. }
  49.  
  50. struct MidiLink *AddMidiLink(struct MidiNode *mi, LONG type, Tag tag, ...)
  51. {    return AddMidiLinkA(mi, type, (struct TagItem *)&tag );
  52. }
  53.  
  54. BOOL SetMidiLinkAttrs(struct MidiLink *mi, Tag tag, ...)
  55. {    return SetMidiLinkAttrsA(mi, (struct TagItem *)&tag );
  56. }
  57.  
  58. void main(int argc, char *argv[])
  59. {    char    *inlinkname = "in.0",
  60.             *outlinkname = "out.0";
  61.     char    mode;
  62.     ULONG    sigs;
  63.  
  64.     if (argc <= 1)
  65.     {
  66.         printf("Usage: linktest mode [inlink outlink]\n");
  67.         exit (5);
  68.     }
  69.  
  70.     mode = argv[1][0];
  71.  
  72.     if (argc == 4)
  73.     {
  74.         inlinkname = argv[2];
  75.         outlinkname = argv[3];
  76.     }
  77.  
  78.     if (CamdBase = OpenLibrary("camd.library",0L))
  79.     {
  80.         if (testnode = CreateMidi(
  81.             MIDI_Name, "test node",
  82.             MIDI_RecvSignal, SIGBREAKB_CTRL_F,
  83.             MIDI_MsgQueue,   100,
  84.             MIDI_SysExSize,   100,
  85.             MIDI_ErrFilter, CMEF_All,
  86.             TAG_DONE ))
  87.         {    printf("Opened Node!\n");
  88.  
  89.             if (outlink = AddMidiLink(testnode, MLTYPE_Sender,
  90.                 MLINK_Name, "Out",
  91.                 MLINK_Location, outlinkname,
  92.                 MLINK_Comment, "Test Output",
  93.                 MLINK_Parse, TRUE,
  94.                 TAG_DONE ))
  95.             {    printf("Opened Output Link!\n");
  96.  
  97.                 if (inlink = AddMidiLink(testnode, MLTYPE_Receiver,
  98.                     MLINK_Name, "In",
  99.                     MLINK_Location, inlinkname,
  100.                     MLINK_Comment, "Test Input",
  101.                     MLINK_PortID,    0,
  102.                     TAG_DONE ))
  103.                 {    MidiMsg        test;
  104.  
  105.                     printf("Opened Input Link!\n");
  106.  
  107.                     if (mode == 'r')
  108.                     {
  109.                         test.mm_Status = 0;
  110.  
  111.                         printf("Waiting...\n");
  112.  
  113.                         sigs = Wait(SIGBREAKF_CTRL_C | SIGBREAKF_CTRL_F);
  114.  
  115.                         if (sigs & SIGBREAKF_CTRL_C) goto end0;
  116.                                         
  117.                         GetMidi(testnode,&test);
  118.  
  119.                         if (test.mm_Status == MS_SysEx)
  120.                         {    int i;
  121.  
  122.                             printf("Maybe SysEx!\n");
  123.  
  124.                             GetSysEx(testnode,b_sys_ex,128);
  125.  
  126.                             for (i=0;i<128;i++)
  127.                             {
  128.                                 printf("0x%02lx\n",(ULONG)b_sys_ex[i]);
  129.                                 if (b_sys_ex[i] == MS_EOX) break;
  130.                             }
  131.  
  132.                             PutSysEx(outlink,a_sys_ex);
  133.                         }
  134.                         else
  135.                         {
  136.                             printf("Got something else: 0x%02lx\n",(ULONG)test.mm_Status);
  137.                         }
  138.                     }
  139.                     else if (mode == 's')
  140.                     {
  141.                         PutSysEx (outlink,r_sys_ex);
  142.  
  143.                         printf("Put SysEx\n");
  144.  
  145.                         test.mm_Status = 0;
  146.  
  147.                         sigs = Wait(SIGBREAKF_CTRL_C | SIGBREAKF_CTRL_F);
  148.  
  149.                         if (sigs & SIGBREAKF_CTRL_C) goto end0;
  150.                                         
  151.                         GetMidi(testnode,&test);
  152.  
  153.                         if (test.mm_Status == MS_SysEx)
  154.                         {    int i;
  155.  
  156.                             printf("Maybe SysEx!\n");
  157.  
  158.                             GetSysEx(testnode,b_sys_ex,128);
  159.  
  160.                             for (i=0;i<128;i++)
  161.                             {
  162.                                 printf("0x%02lx\n",(ULONG)b_sys_ex[i]);
  163.                                 if (b_sys_ex[i] == MS_EOX) break;
  164.                             }
  165.                         }
  166.                         else
  167.                         {
  168.                             printf("Got something other than SysEx?\n");
  169.                         }
  170.                     }
  171.                 }
  172.             }
  173. end0:        DeleteMidi(testnode);
  174.         }
  175.         CloseLibrary(CamdBase);
  176.     }
  177.  
  178.     exit(0);
  179. }
  180.